package de.grosjohann.android.feuerwehr;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import de.grosjohann.android.feuerwehr.service.FMSNotificationService;
import de.grosjohann.android.feuerwehr.service.IntentServiceFacade;
import de.grosjohann.android.feuerwehr.service.WeatherNotificationService;
import de.grosjohann.android.feuerwehr.util.PrefsUtil;

public class BootCompletedReceiver
  extends BroadcastReceiver {

  private static final String NAME = "BootCompletedReceiver";

  @Override
  public void onReceive(Context ctx, Intent intent) {
    Log.i(NAME, "Boot complete");

    if (PrefsUtil.getBoolean(ctx, R.string.prefKeyAutostart, false)) {
      Log.i(NAME, "Autostart active");

      IntentServiceFacade.startRepeating(ctx, FMSNotificationService.class);

      IntentServiceFacade.startRepeating(ctx, WeatherNotificationService.class);
    }
  }

}
